<?php
class InnerMenuTable{
	var $id ;
	var $menus = array();
	var $focusId ;
	var $height ;

	function InnerMenuTable($id){
		$this->boxid = $id ;
		if($this->boxid == ""){
			$this->boxid = "imtbox";
		}
	}

	function addMenu($id){
		$menu = array();
		$menu["id"] = $id;
		array_push($this->menus,$menu);
	}

	function checkFocus(){
		$first = "";
		if(count($this->menus) > 0){
			$first = $this->menus[0]["id"] ;
		}
		$this->focusId = get_parameter($this->boxid,$first);
	}

	function getFocusId(){
		return $this->focusId ;
	}

	function printHtmlHead(){
		print $this->getHtmlHead();
	}
	
	function printHtmlFoot(){
		print $this->getHtmlFoot();
	}

	function getHtmlHead(){
		$this->checkFocus();

		$aaid  = "imt_".$this->boxid ;

		$html  = "<aazone class='' id='$aaid'>";
		$html .= "<table class='innerMenuTable'>";
		$html .= "<tr>";
		$html .= "	<td class='innerMenuTableTitle'>";

		for($i=0;$i<count($this->menus);$i++){
			$menu = $this->menus[$i] ;

			$isme = $menu["id"] == $this->focusId ;
			$clas = $isme ? "sim-focus" : "sim-blur";
			$name = $this->boxid ;
			$value = $menu["id"];

			$html .= ($i > 0)? "<span class='spanInnerSpace'>|</span>" : "";

			$html .= "<a href='#' onclick=\"lazy_aa({'$name':'$value'},['$aaid'])\">";
			$html .= "<span class='spanInnerMenu $clas'>" . label($this->menus[$i]["id"]) . "</span>";
			$html .= "</a>";
		}
				
		$html .= "	</td>";
		$html .= "</tr>";
		$html .= "<tr>";
		$html .= "	<td class='innerMenuTableBody'>";
		$html .= "	<div style='height:".$this->height.";overflow-y:scroll;'>";

		return $html ;
	}

	function getHtmlFoot(){
		$crlf = "\r\n";
		$tab = "\t";
		
		$html  = "";
		$html .= "	</div>";
		$html .= "	</td> $crlf";
		$html .= "</tr> $crlf";
		$html .= "</table> $crlf";
		$html .= "</aazone>";

		return $html;
	}

	function setHeight($height){
		$this->height = $height ;
	}
	
}


print "<link rel='stylesheet' href='/p5/components/InnerMenuTable.css'></link>" ;